package com.aiobc.business.appInfo.controller;

import com.aiobc.business.appInfo.domain.AppApproval;
import com.aiobc.business.appInfo.service.IAppApprovalService;
import com.aiobc.common.core.web.controller.BaseController;
import com.aiobc.common.core.web.domain.AjaxResult;
import com.aiobc.common.core.web.page.TableDataInfo;
import com.aiobc.common.log.annotation.Log;
import com.aiobc.common.log.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * APP审批Controller
 *
 * @author ruoyi
 * @date 2021-10-20
 */
@Api(value = "app审批", tags = "app审批")
@RestController
@RequestMapping("/approval")
public class AppApprovalController extends BaseController {
    @Autowired
    private IAppApprovalService appApprovalService;

    /**
     * 查询APP审批列表
     */
    @GetMapping("/list")
    @ApiOperation("app审批-查询APP审批列表")
    public TableDataInfo list(AppApproval appApproval) {
        startPage();
        List<AppApproval> list = appApprovalService.selectAppApprovalList(appApproval);
        return getDataTable(list);
    }

    /**
     * 获取APP审批详细信息
     */
    @GetMapping(value = "/{approvalId}")
    @ApiOperation("app审批-获取APP审批详细信息")
    public AjaxResult getInfo(@PathVariable("approvalId") String approvalId) {
        return AjaxResult.success(appApprovalService.selectAppApprovalByApprovalId(approvalId));
    }

    /**
     * 新增APP审批
     */
    @Log(title = "APP审批", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("app审批-新增APP审批")
    public AjaxResult add(@RequestBody AppApproval appApproval) {
        return toAjax(appApprovalService.save(appApproval));
    }

    /**
     * 修改APP审批
     */
    @Log(title = "APP审批", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("app审批-修改APP审批")
    public AjaxResult edit(@RequestBody AppApproval appApproval) {
        return toAjax(appApprovalService.updateAppApproval(appApproval));
    }

    /**
     * 删除APP审批
     */
    @Log(title = "APP审批", businessType = BusinessType.DELETE)
    @DeleteMapping("/{approvalIds}")
    @ApiOperation("app审批-删除APP审批")
    public AjaxResult remove(@PathVariable String[] approvalIds) {
        return toAjax(appApprovalService.deleteAppApprovalByApprovalIds(approvalIds));
    }
}
